package com.lijiajia.cloud.common.security.access.expression;

import com.lijiajia.cloud.common.security.access.Authority;
import com.lijiajia.cloud.common.security.access.Role;
import org.springframework.security.access.expression.SecurityExpressionRoot;
import org.springframework.security.core.Authentication;

/**
 * 自定义 安全表达式
 *
 * @author lijiajia
 * @since 2019-05-30
 */
public class CustomSecurityExpressionRoot extends SecurityExpressionRoot {
	public final Role role;

	public final Authority authority;

	public CustomSecurityExpressionRoot(Authentication auth,
										Role role,
										Authority authority) {
		super(auth);
		this.role = role;
		this.authority = authority;
	}

	public final boolean isSuperAdmin() {
		return hasRole(role.SUPER_ADMIN);
	}


}
